const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
+const Lang = imports.lang;
const St = imports.gi.St;
const Main = imports.ui.main;
return pos;
}
-function makeCloseButton() {
- let closeButton = new St.Button({ style_class: 'notification-close'});
+const CloseButton = new Lang.Class({
+ Name: 'CloseButton',
+ Extends: St.Button,
+
+ _init: function(boxpointer) {
+ this.parent({ style_class: 'notification-close'});
+
+ // This is a bit tricky. St.Bin has its own x-align/y-align properties
+ // that compete with Clutter's properties. This should be fixed for
+ // Clutter 2.0. Since St.Bin doesn't define its own setters, the
+ // setters are a workaround to get Clutter's version.
+ this.set_x_align(Clutter.ActorAlign.END);
+ this.set_y_align(Clutter.ActorAlign.START);
+
+ // XXX Clutter 2.0 workaround: ClutterBinLayout needs expand
+ // to respect the alignments.
+ this.set_x_expand(true);
+ this.set_y_expand(true);
+
+ this._boxPointer = boxpointer;
+ if (boxpointer)
+ this._boxPointer.connect('arrow-side-changed', Lang.bind(this, this._sync));
+ },
+
+ _computeBoxPointerOffset: function() {
+ if (!this._boxPointer || !this._boxPointer.actor.get_stage())
+ return 0;
+
+ let side = this._boxPointer.arrowSide;
+ if (side == St.Side.TOP)
+ return this._boxPointer.getArrowHeight();
+ else
+ return 0;
+ },
- // This is a bit tricky. St.Bin has its own x-align/y-align properties
- // that compete with Clutter's properties. This should be fixed for
- // Clutter 2.0. Since St.Bin doesn't define its own setters, the
- // setters are a workaround to get Clutter's version.
- closeButton.set_x_align(Clutter.ActorAlign.END);
- closeButton.set_y_align(Clutter.ActorAlign.START);
+ _sync: function() {
+ let themeNode = this.get_theme_node();
- // XXX Clutter 2.0 workaround: ClutterBinLayout needs expand
- // to respect the alignments.
- closeButton.set_x_expand(true);
- closeButton.set_y_expand(true);
+ let offY = this._computeBoxPointerOffset();
+ this.translation_x = themeNode.get_length('-shell-close-overlap-x')
+ this.translation_y = themeNode.get_length('-shell-close-overlap-y') + offY;
+ },
- closeButton.connect('style-changed', function() {
- let themeNode = closeButton.get_theme_node();
- closeButton.translation_x = themeNode.get_length('-shell-close-overlap-x');
- closeButton.translation_y = themeNode.get_length('-shell-close-overlap-y');
- });
+ vfunc_style_changed: function() {
+ this._sync();
+ this.parent();
+ },
+});
- return closeButton;
+function makeCloseButton(boxpointer) {
+ return new CloseButton(boxpointer);
}
function ensureActorVisibleInScrollView(scrollView, actor) {
const Clutter = imports.gi.Clutter;
const Lang = imports.lang;
const Meta = imports.gi.Meta;
-const St = imports.gi.St;
const Shell = imports.gi.Shell;
+const Signals = imports.signals;
+const St = imports.gi.St;
const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
this._muteInput();
},
+ get arrowSide() {
+ return this._arrowSide;
+ },
+
_muteInput: function() {
if (this._capturedEventId == 0)
this._capturedEventId = this.actor.connect('captured-event',
this._container.queue_relayout();
return false;
}));
+
+ this.emit('arrow-side-changed');
}
},
updateArrowSide: function(side) {
this._arrowSide = side;
this._border.queue_repaint();
+
+ this.emit('arrow-side-changed');
},
getPadding: function(side) {
return this.actor.get_theme_node().get_length('-arrow-rise');
}
});
+Signals.addSignalMethods(BoxPointer.prototype);